#include "widget.h"
#include "ui_widget.h"
#include<QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    ui->lineEdit_name->setPlaceholderText("请输入姓名");//提示信息
    ui->lineEdit_name->setClearButtonEnabled(true);//一键清空

    ui->lineEdit_password->setPlaceholderText("请输入密码");
    ui->lineEdit_password->setEchoMode(QLineEdit::Password);//回显样式
    ui->lineEdit_password->setClearButtonEnabled(true);//一键清空

    ui->lineEdit_tel->setPlaceholderText("请输入电话");
    ui->lineEdit_tel->setClearButtonEnabled(true);
    //ui->lineEdit_tel->setInputMask("0000-000-0000");//434
    //ui->lineEdit_tel->setCursorPosition(0);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::on_pushButton_clicked()
{
    QString gender = ui->radioButton_male->isChecked() ? "男" : "女";
    qDebug() << "姓名: " << ui->lineEdit_name->text()
        << "密码: " << ui->lineEdit_password->text()
        << "性别: " << gender
        << "手机: " << ui->lineEdit_tel->text();
}


void Widget::on_checkBox_toggled(bool checked)
{
    if(checked)
    {
        ui->lineEdit_password->setEchoMode(QLineEdit::Normal);
    }
    else
    {
         ui->lineEdit_password->setEchoMode(QLineEdit::Password);
    }
}

